@extends('app')

@section('content')
    <div class="layui-card" style="margin-bottom: 0;">
        @include('layouts.breadcrumb')

        <div class="layui-tab-content">
            <form class="layui-form">
                <blockquote class="layui-elem-quote quoteBox" >
                    <div class="layui-inline">
                        <div class="layui-input-inline">
                            <select name="type">
                                <option value="">意见类型</option>
                                <option value="1" @if($type==1) selected @endif>bug</option>
                                <option value="2" @if($type==2) selected @endif>优化</option>
                                <option value="3" @if($type==3) selected @endif>新增</option>
                                <option value="4" @if($type==4) selected @endif>其他</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <div class="layui-input-inline">
                            <select name="status">
                                <option value="">状态</option>
                                <option value="1" @if($status==1) selected @endif>采纳</option>
                                <option value="2" @if($status==2) selected @endif>不采纳</option>
                                <option value="3" @if($status==3) selected @endif>提出</option>
                                <option value="4" @if($status==4) selected @endif>开发中</option>
                                <option value="5" @if($status==5) selected @endif>完结</option>
                            </select>
                        </div>
                    </div>
                    <a class="layui-btn search_btn" data-type="reload" lay-submit lay-filter="search" style="margin-left: 3px"><i class="layui-icon layui-icon-search"></i>查询</a>
                </blockquote>
            </form>
            <div class="layui-tab-item layui-show">
                <table class="layui-hide" id="model" lay-filter="model"></table>
            </div>
        </div>
    </div>


    {{--表列操作--}}
    <script type="text/html" id="operate">
        <a class="layui-btn layui-btn-xs" lay-event="check">处理</a>
    </script>
@endsection

@section('js')
    <script>
        layui.config({
            version:false
        }).use('table', function(){
            var table = layui.table;
            var form = layui.form;
            var $   = layui.$;

            form.on('submit(search)', function(data){
                var field = data.field;
                //执行重载
                table.reload('model', {
                    page: {
                        curr: 1 //重新从第 1 页开始
                    },
                    where: field
                });
            });

            table.render({
                elem: '#model',
                url:'/opinion/index',
                cellMinWidth: 95, //全局定义常规单元格的最小宽度，layui 2.2.1 新增
                height: 'full-150',
                method : 'POST',
                page: true, //开启分页
                defaultToolbar: ['filter', 'print', 'exports'],
                toolbar:'#upload',
                limit:20,
                loading:true,
                rowStyle: function (index, item) {//index第几行，row当前行的值
                    return 'data-id="'+item.id+'" ';
                },
                cols: [[
                    {type: 'checkbox', fixed: 'left'},
                    {field:'id', title: 'ID',align:'center'},
                    {field:'type', title: '意见类型',align:'center',templet:function(item){
                            return item.type==1?'bug':(item.type==2?'优化':(item.type==3?'新增':'其他'));
                        }
                    },

                    {field:'title',width:'180',title: '意见标题'},
                    {field:'content',width:'650',title: '意见内容'},
                    {field:'status',width:'80',title: '状态',templet:function(item){
                            return item.status==1?'采纳':(item.status==2?'不采纳':(item.status==3?'提出':(item.status==4?'开发中':'完结')));
                        }
                    },
                    {field:'created_at',width:'180',title: '创建时间'},
                    {field:'updated_at',width:'180',title: '更新时间'},
                    {title: '操作',width:200, align:'center', fixed: 'right', toolbar: '#operate'}
                ]]
            });

            //列操作
            table.on('tool(model)',function (obj) {
                if(obj.event === 'check'){
                    //处理
                    newWindow('处理','/opinion/check?id='+obj.data.id,'400','400');
                }
            });
        })
    </script>
@endsection